package com.gopay.solution.dao.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.solution.domain.po.SsGpComConfDtl;

/**
 * 佣金额度设置明细方案DAO
 * @SsGpComConfDtlDAOImpl.java
 * @author Ryan
 * @2014年4月18日 下午2:03:36  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("ssGpComConfDtlDAO")
public class SsGpComConfDtlDAOImpl extends SolutionRuleDtlDAOImpl<SsGpComConfDtl, Serializable> {

    @Override
    public SsGpComConfDtl getByPk(Serializable id) {
        return find(SsGpComConfDtl.class, id);
    }

    @Override
    public List<SsGpComConfDtl> listBySolutionId(long solutionId) {
        String hql ="from SsGpComConfDtl dtl where dtl.solutionId = :SolutionId order by dtl.sq";
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("SolutionId", solutionId);
        return findByHql(hql, param);
    }

    @Override
    public boolean delBySolutionId(long solutionId) {
        
        List<SsGpComConfDtl> dtls = listBySolutionId(solutionId);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

    @Override
    public List<SsGpComConfDtl> listBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        String hql = "from SsGpComConfDtl dtl where dtl.solutionId = :SolutionId and dtl.gopayIntTxnCd = :GopayIntTxnCd order by dtl.sq";
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("SolutionId", solutionId);
        params.put("GopayIntTxnCd", intTxnCd);
        
        return findByHql(hql, params);
    }

    @Override
    public boolean delBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        List<SsGpComConfDtl> dtls = listBySoluIdAndIntTxnCd(solutionId, intTxnCd);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

}
